<template>
  <div id="app" />
</template>

<script>
// import IOSDialog from '@/components/IOS-dialog.vue'
export default {
  // components: { IOSDialog },
  data() {
    return {
      isLoaded: false
    }
  },
  watch: {
    // '$route': { //
    //   handler(to, from) {
    //     this.init()
    //   },
    //   immediate: true
    // }
  },
  created() {
  },
  mounted() {
    this.init()
  },
  methods: {
    init() {
      // let BMap = window.BMapGL
      // const that = this
      // eslint-disable-next-line
      AMap.plugin('AMap.Geolocation', () => {
        // eslint-disable-next-line
        var geolocation = new AMap.Geolocation({
          // 是否使用高精度定位，默认：true
          enableHighAccuracy: true,
          // 是否使用安卓定位sdk用来进行定位，需要安卓端sdk配合
          useNative: true,
          // 设置定位超时时间，默认：无穷大
          timeout: 10000
        })

        geolocation.getCurrentPosition((status, result) => { // 获取用户当前的精确位置
          alert(status)
          alert(JSON.stringify(result))
          if (status == 'complete') {
            alert(JSON.stringify(result))
            // console.log(result.position[0], result.position[1])
            window.parent.postMessage(JSON.stringify(result), '*')
            // that.showCode = result.adcode.substring(0, 4)
            // if (that.showCode.length === 4) {
            //   this.surePosition(result.position[0], result.position[1])
            // } else {
            //   that.showCity = '未获取定位'
            //   that.getServiceType(0)
            // }
          } else {
            // console.log(result.position[0], result.position[1])
            geolocation.getCityInfo((status, result) => { // 只能获取当前用户所在城市和城市的经纬度
              alert(status)
              alert(JSON.stringify(result))
              // if (status == 'complete') {
              //   this.surePosition(result.position[0], result.position[1])
              // } else {
              //   that.showCity = '未获取定位'
              //   that.getServiceType(0)
              // }
            })
          }
        })
      })
    },
    onload() {
      document.querySelector('.fakeloader').style.opacity = 0
      document.querySelector('.fakeloader').style.transform = 'scale(5)'
      window.setTimeout(() => {
        this.isLoaded = true
      }, 1000)
    }

  }
}
</script>

<style lang="scss">
#app{
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 10;
  background-size: 100%;
  // padding: 30px 25px;
  box-sizing: border-box;
  .fakeloader{
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s;
    // transform-origin: center;
  }
  iframe{
    width: 100%;
    height: 100%;
  }
}
</style>
